home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / frexp.s < prev    next >
Text File  |  1991-09-24  |  2KB  |  68 lines

  1. # 1 "frexp.cpp"
  2. # remove exponent from floating point number
  3. # C Interface
  4. # double frexp(double value, int *eptr)
  5. #
  6. # returns significand (#significand# < 1)
  7. #       in *eptr returns n such that value = significand * 2**n
  8. ###############################################################################
  9. # hacked for the 68881 by Michael Ritzert, 5.10.90
  10. ##############################################################################
  11. # addresses of the 68881 data port. This choice is fastest when much data is
  12. # transferred between the two processors.
  13.  
  14. comm =     -6    |    fpu command reg
  15. resp =    -16    |    fpu response reg
  16. zahl =      0    |    fpu data reg
  17.  
  18. # a1:    fpu base register
  19. # a0:    pointer to n
  20. #     sp@(12) address of resulting exponent (n)
  21.  
  22. # waiting loop ...
  23. #
  24. # wait:
  25. # ww:    cmpiw    #0x8900,a0@(resp)
  26. #     beq    ww
  27. # is coded directly by
  28. #    .long    0x0c688900, 0xfff067f8                 (fpu base a1)
  29. # and
  30. # www:    tst.w    a0@(resp)
  31. #    bmi.b    www
  32. # is coded by
  33. #    .word    0x4a68,0xfff0,0x6bfa        | test
  34.     
  35.     .text; .even
  36.  
  37. .globl _frexp
  38.     
  39.     lea    0xfffa50,a0
  40.     movew    #0x5418,a0@(comm)    | load first argument to fp0
  41.     cmpiw    #0x8900,a0@(resp)    | check
  42.     movel    a7@(4),a0@
  43.     movel    a7@(8),a0@
  44.  
  45.     movew    #0x009f,a0@(comm)    | fgetman fp0,fp1
  46.     .word    0x4a68,0xfff0,0x6bfa    | test
  47.  
  48.     movew    #0x001e,a0@(comm)    | fgetexp fp0,fp0
  49.     moveal    a7@(12),a1        | address of n while the fpu is active
  50.     .word    0x4a68,0xfff0,0x6bfa    | test
  51.  
  52.     movew    #0x7080,a0@(comm)    | fetch exp (fmovew from fp1)
  53.     .long    0x0c688900, 0xfff067f8
  54.     movew    a0@,a1@            | return exp
  55.  
  56.  
  57.  
  58.  
  59.  
  60.     movew    #0x7400,a0@(comm)    | now fetch significand
  61.     .long    0x0c688900, 0xfff067f8
  62.     movel    a0@,d0
  63.     movel    a0@,d1
  64.     btst    #31,a7@(4)        | test sign of 1st arg
  65.     bge    fini            | arg neg ?
  66.     bset    #31,d0            | =>  negate result
  67. fini:    rts
  68.